<?php

	require '../conn.php';
//	$tab = 0;
	
//	if ($_REQUEST['tab'] != '') {
//		$limit = $_REQUEST['tab'];
//	}
	
	$query = "SELECT * FROM advertising,shop WHERE advertising.shop_id=shop.shop_id";	// WHERE tabbar=".$tab;
	$result = mysql_query($query);
	$arr = array();
	while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
	{
		$shopId = $row['shop_id'];
		$imageQuery = "SELECT * FROM images WHERE shop_id=".$shopId;
		$imageResult = mysql_query($imageQuery);
		$imageArray = array();
		while ($imageRow = mysql_fetch_array($imageResult, MYSQL_ASSOC)) {
			$imageArray[] = $imageRow;
		}
		$row['images'] = $imageArray;
		$arr[] = $row;
	}
	
	$json_str = json_encode($arr);
	echo '{"advertising":'.$json_str.'}';
?>
